teach gdb reader to read autoroute information. (#566)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 24 May 2020 16:39:01 +0000 (10:39 -0600)
committerGitHub <noreply@github.com>
Sun, 24 May 2020 16:39:01 +0000 (10:39 -0600)
gdb.cc
reference/gdb-sample-v3-autoroute.gdb [new file with mode: 0644]
reference/gdb-sample-v3-autoroute.gpx [new file with mode: 0644]
testo.d/gdb.test

diff --git a/gdb.cc b/gdb.cc
index d32664cabc49a6bae18d97931ebd7e81b9e94c6d..681f89c796683495590ee3bc58424eb50f56f474 100644 (file)
--- a/gdb.cc
+++ b/gdb.cc
@@ -19,6 +19,9 @@
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+  A format description obtained from reverse-engineering is at 
+  https://www.memotech.franken.de/FileFormats/Garmin_MPS_GDB_and_GFI_Format.pdf
 */
 
 #include <cmath>                   // for fabs
@@ -840,7 +843,35 @@ read_route()
 
     int color_idx = FREAD_i32;
     rte->line_color.bbggrr = gt_color_value(color_idx);
-    FREAD(buf, 1);                     /* ?????????????????????????????????? */
+
+    int autoroute = FREAD_C;
+    if (autoroute == 1) {
+      FREAD(buf, 6); /* unknown bytes */
+      int route_style = FREAD_C;
+      int calc_type = FREAD_i32;
+      int vehicle_type = FREAD_C;
+      int road_selection = FREAD_i32;
+      double driving_speed[5];
+      driving_speed[0] = FREAD_DBL;
+      driving_speed[1] = FREAD_DBL;
+      driving_speed[2] = FREAD_DBL;
+      driving_speed[3] = FREAD_DBL;
+      driving_speed[4] = FREAD_DBL;
+      FREAD(buf, 8); /* unknown bytes */
+#if GDB_DEBUG
+      DBG(GDB_DBG_RTE, 1)
+      printf(MYNAME "-rte_pt: autoroute info: route style %d, calculation type %d, vehicle type %d, road selection %d\n"
+                    "                            driving speeds (kph) %.0f, %.0f, %.0f, %.0f, %.0f\n",
+           route_style, calc_type, vehicle_type, road_selection,
+           driving_speed[0], driving_speed[1], driving_speed[2], driving_speed[3], driving_speed[4]);
+#else
+      Q_UNUSED(route_style);
+      Q_UNUSED(calc_type);
+      Q_UNUSED(vehicle_type);
+      Q_UNUSED(road_selection);
+      Q_UNUSED(driving_speed);
+#endif
+    }
 
     rte->rte_desc = fread_cstr();
 #if 0
diff --git a/reference/gdb-sample-v3-autoroute.gdb b/reference/gdb-sample-v3-autoroute.gdb
new file mode 100644 (file)
index 0000000..01764df
Binary files /dev/null and b/reference/gdb-sample-v3-autoroute.gdb differ
diff --git a/reference/gdb-sample-v3-autoroute.gpx b/reference/gdb-sample-v3-autoroute.gpx
new file mode 100644 (file)
index 0000000..4cea7a6
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx version="1.0" creator="GPSBabel - https://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
+  <time>1970-01-01T00:00:00Z</time>
+  <bounds minlat="44.521450996" minlon="-68.208982944" maxlat="44.522766536" maxlon="-68.204090595"/>
+  <wpt lat="44.522766452" lon="-68.208928211">
+    <ele>37.273</ele>
+    <name>0001</name>
+    <cmt>Get on Manor Ln and drive south</cmt>
+    <desc>Get on Manor Ln and drive south</desc>
+    <sym>Waypoint</sym>
+  </wpt>
+  <wpt lat="44.522588253" lon="-68.208982944">
+    <ele>37.160</ele>
+    <name>0002</name>
+    <cmt>Turn left onto Us1</cmt>
+    <desc>Turn left onto Us1</desc>
+    <sym>Waypoint</sym>
+  </wpt>
+  <wpt lat="44.521901608" lon="-68.204090595">
+    <ele>40.863</ele>
+    <name>0003</name>
+    <cmt>Turn right onto Miramar Ave</cmt>
+    <desc>Turn right onto Miramar Ave</desc>
+    <sym>Waypoint</sym>
+  </wpt>
+  <wpt lat="44.521506736" lon="-68.204822838">
+    <ele>40.180</ele>
+    <name>0004</name>
+    <cmt>0004</cmt>
+    <desc>0004</desc>
+    <sym>Waypoint</sym>
+  </wpt>
+  <wpt lat="44.522766536" lon="-68.208928127">
+    <time>2020-05-22T12:02:08Z</time>
+    <name>7 Manor Ln</name>
+    <cmt>7 Manor Ln
+Sullivan Twn, ME, 04664, USA</cmt>
+    <desc>7 Manor Ln
+Sullivan Twn, ME, 04664, USA</desc>
+    <sym>Flag, Blue</sym>
+  </wpt>
+  <wpt lat="44.521450996" lon="-68.204820156">
+    <time>2020-05-22T12:02:28Z</time>
+    <name>Acadia Bay Inn</name>
+    <cmt>Acadia Bay Inn
+12 Miramar Ave
+Sullivan Twn, Maine, 04664, United States
+207-422-0127</cmt>
+    <desc>Acadia Bay Inn
+12 Miramar Ave
+Sullivan Twn, Maine, 04664, United States
+207-422-0127</desc>
+    <sym>Lodging</sym>
+  </wpt>
+  <rte>
+    <name>7 Manor Ln to Acadia Bay Inn</name>
+    <rtept lat="44.522766536" lon="-68.208928127">
+      <time>2020-05-22T12:02:08Z</time>
+      <name>7 Manor Ln</name>
+      <cmt>7 Manor Ln
+Sullivan Twn, ME, 04664, USA</cmt>
+      <desc>7 Manor Ln
+Sullivan Twn, ME, 04664, USA</desc>
+      <sym>Flag, Blue</sym>
+    </rtept>
+    <rtept lat="44.522766452" lon="-68.208928211">
+      <ele>37.273</ele>
+      <name>0001</name>
+      <cmt>Get on Manor Ln and drive south</cmt>
+      <desc>Get on Manor Ln and drive south</desc>
+      <sym>Waypoint</sym>
+    </rtept>
+    <rtept lat="44.522588253" lon="-68.208982944">
+      <ele>37.160</ele>
+      <name>0002</name>
+      <cmt>Turn left onto Us1</cmt>
+      <desc>Turn left onto Us1</desc>
+      <sym>Waypoint</sym>
+    </rtept>
+    <rtept lat="44.521901608" lon="-68.204090595">
+      <ele>40.863</ele>
+      <name>0003</name>
+      <cmt>Turn right onto Miramar Ave</cmt>
+      <desc>Turn right onto Miramar Ave</desc>
+      <sym>Waypoint</sym>
+    </rtept>
+    <rtept lat="44.521506736" lon="-68.204822838">
+      <ele>40.180</ele>
+      <name>0004</name>
+      <cmt>0004</cmt>
+      <desc>0004</desc>
+      <sym>Waypoint</sym>
+    </rtept>
+    <rtept lat="44.521450996" lon="-68.204820156">
+      <time>2020-05-22T12:02:28Z</time>
+      <name>Acadia Bay Inn</name>
+      <cmt>Acadia Bay Inn
+12 Miramar Ave
+Sullivan Twn, Maine, 04664, United States
+207-422-0127</cmt>
+      <desc>Acadia Bay Inn
+12 Miramar Ave
+Sullivan Twn, Maine, 04664, United States
+207-422-0127</desc>
+      <sym>Lodging</sym>
+    </rtept>
+  </rte>
+</gpx>
index 847518388327a7754b66488bd826e8c670a16d16..05aa812b5d571320428afc1f9e06a205b8e2a3c5 100644 (file)
@@ -25,3 +25,7 @@ compare ${REFERENCE}/gdb-sample.gpx ${TMPDIR}/gdb-sample_v2.gpx
 
 gpsbabel -i gdb,via -f ${REFERENCE}/gdb-sample-v3.gdb -o gpx -F ${TMPDIR}/gdb-sample_v3.gpx
 compare ${REFERENCE}/gdb-sample.gpx ${TMPDIR}/gdb-sample_v3.gpx
+
+# don't choke if autoroute information is present.
+gpsbabel -i gdb -f ${REFERENCE}/gdb-sample-v3-autoroute.gdb -o gpx -F ${TMPDIR}/gdb-sample-v3-autoroute.gpx
+compare ${REFERENCE}/gdb-sample-v3-autoroute.gpx ${TMPDIR}/gdb-sample-v3-autoroute.gpx